import Qt 4.7
XmlListModel {
    id: model  

    property string searchPhrase: "qtquick"
    property string url: ""

    function refresh() {
        model.url = 'http://search.twitter.com/search.atom?&q='+searchPhrase+'&show_user=true'
        model.reload();
    }

    source: url
    query: "/feed/entry"
    XmlRole { name: "statusText"; query: "content/string()" }
    XmlRole { name: "timeStamp"; query: "published/string()" }
    XmlRole { name: "source"; query: "twitter:source/string()" }
    XmlRole { name: "userImage"; query: "link[@rel = 'image']/@href/string()" }

    namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom'; " +
                           "declare namespace twitter=\"http://api.twitter.com/\";";

    onStatusChanged: {
        if (status==XmlListModel.Ready && model.url != "") {
            main.state = "MainState";
        }
    }
}